<template>
  <div class="cart">
    <!-- 导航 -->
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{ length }})</div>
    </nav-bar>
    <!-- 商品列表 -->
    <cart-list />

    <!-- 底部购买 -->
    <cart-bottom-bar />
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar.vue";
import { mapGetters } from "vuex";
import CartList from "./childComps/CartList.vue";
import CartBottomBar from "./childComps/CartBottomBar.vue";

export default {
  components: { NavBar, CartList, CartBottomBar },
  computed: {
    //mapGetters辅助函数仅仅是将store中的getter映射到局部计算属性︰
    //解构  两种语法
    // ...mapGetters(["cartLength"]),
    ...mapGetters({
      length: "cartLength",
    }),
  },
};
</script>

<style scoped>
.cart {
  height: 100%;
  /* position: relative; */
}
.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
}
</style>